<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="author" content="江阳小道">
    <meta name="viewport" content="width=device-width, initial-scale=0.5, maximum-scale=0.5, user-scalable=no">
    <title>深呼吸体验之旅摄影作品大赛</title>
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">

    <!-- No Baidu Siteapp-->
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="__PUBLIC__/css/reset.css">
    <link rel="stylesheet" href="__PUBLIC__/css/base.css">
    <link rel="stylesheet" href="__PUBLIC__/css/main.css">

</head>
<body>
<div class="vote-page">
    <!--&lt;!&ndash;背景音乐&ndash;&gt;-->
    <!--<audio controls="controls" autoplay="autoplay" loop="loop" hidden="hidden">-->
        <!--<source src="__PUBLIC__/vol.mp3" type="audio/mpeg">-->
    <!--</audio>-->
    <!--<div class="audio_btn" style="">-->
            <!--<img src="__PUBLIC__/img/audio_open.png"/>-->
        <!--</div>-->
    <!--<img class="header" src="__PUBLIC__/img/vote-header.png" alt="">-->
    <div class="content">
        <ul class="user-ul" id="rows">
            <volist name="show" id="vo">
                <li class="user-item clearfix">
                    <div class="user-item-content">
                        <span class="number">{$i}</span>
                        <a class="avatar" href="#"><img src="{$vo.headimg}" alt=""></a>
                        <p class="info">{$vo.name} {$vo.introduction} <span style="color:red">{$vo.number}票</span></p>
                        <!-- <p class="info">{$vo.number} 票</p> -->

                        <a class="select" data-id="{$vo.pk_id}" href="javascript:;"></a>
                    </div>
                </li>
            </volist>

        </ul>
    </div>
    <div class="footer">
        <p class="select-tip" data-play="{$play}">已选择（0）人</p>
        <a class="confirm hidden" href="javascript:;"><img src="__PUBLIC__/img/bottom-zan.png" alt=""></a>
    </div>

</div>
<div class="user-dialog translucent-bg hidden">
    <div class="content">
        <a class="close" href="#"><img src="__PUBLIC__/img/icon-close.png" alt=""></a>
        <div class="user-dialog-body">
            <div class="head">
                <img class="avatar" src="__PUBLIC__/img/lufei.jpg" alt="">
                <div class="head-right">
                    <p class="name">{$info['name']}</p>
                    
                    <p class="vote-num"></p>
                </div>
            </div>
			<!--个人信息-->
            <p class="info" id="v_info"></p>
            <div class="pic-show">
                <ul class="pic-show-ul">
                    <li>
                        <img src="http://127.0.0.1/upload/2_1.jpg" />
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>

<div class="no-prize-dialog prize-remind translucent-bg no-prize" id="no6" style="display: none" >
    <!--<div class="content">-->
    <a class="close" href="#"></a>
    <div class="prize-info">
        <img src="__PUBLIC__/img/end.png" alt="">
    </div>
    <div class="footer">
        <!--<a class="close" href="#"><img src="__PUBLIC__/img/btn-know.png" alt=""></a>-->
        <a class="share"><img src="__PUBLIC__/img/share-friend.png" alt=""></a>
    </div>

</div>


<!-- 微信分享 -->
<div class="wx-share translucent-bg hidden">
    <img src="__PUBLIC__/img/wx-share.png" alt="">
</div>


<!-- 投票结束再次点击按钮 -->
<div class="vote-end-dialog prize-remind translucent-bg" id="return-zan" style="display:none;">
    <div class="content">
        <a class="close" href="#"></a>
        <div class="footer">

            <a class="share"><img src="__PUBLIC__/img/share-friend.png" alt=""></a>
        </div>

        <a href="javascript:;" class="show-code recode" style="display:none;"></a>

    </div>
</div>



<script src="__PUBLIC__/js/lib/zepto.min.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="__PUBLIC__/js/main.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $(".avatar").tap(function (event) {
            var vid = $(this).parent().children('.select').attr('data-id'); //获取指定元素之后的class=select的兄弟节点的data-id属性的值
            var param = {pk_id:vid};

//            if($(".select-tip").attr('data-play') <= 0){
//
//                $("#return-zan").show();
//                $("#return-zan").removeClass("hidden");

//            }else{
                $.post("{:U('Member/Member/info')}", param, function(data, textStatus, xhr) {
                    $("#v_info").text(data['info']['introduction']);
                    $(".avatar").attr('src',data.photo_arr[0]);
                    // $(".name").text(data['info']['name']);
                    $(".name").text(data['info']['name']+' '+data['info']['introduction']);
                    $(".vote-num").html(data['info']['number']+' 票');
                    var object =$(".pic-show-ul");
                    object.empty(); //将指定元素下的节点及内容全部删除
                    var pic_len = data.photo_arr.length; //获取图片的长度（张数）
                    //往容器加入图片
                    for(var i=0;i<pic_len;i++){
                        object.append(
                                '<li><img src="'+data.photo_arr[i]+'" /></li>'
                        );
                    }
                },"json");
//            }


            $(".user-dialog").removeClass("hidden");
        });
        $(".close").tap(function (event) {
            $(".user-dialog").addClass("hidden");
        });
        //选候选人
        $(".select").tap(function(){
            var obj = $(this),
                    len = $("#rows .ok").length; //获取指定元素的数量（长度）
            if(obj.hasClass("ok")){
                //取消选中
                obj.removeClass('ok'); //向指定元素移除类
                if(len===1){
                    $(".select-tip").removeClass("hidden");
                    $(".confirm").addClass("hidden");
                }
                $(".select-tip").text("已选择（"+(len-1)+"）人");
            }else{
                obj.addClass('ok'); //向指定元素增加类
                if(len===0){
                    $(".select-tip").addClass("hidden");
                    $(".confirm").removeClass("hidden");
                }
                $(".select-tip").text("已选择（"+(len+1)+"）人");
            }
        });


//        if($(".select-tip").attr('data-play') <= 0) {
//
//            $("#return-zan").show();
//            $("#return-zan").removeClass("hidden");
//        }else{
            //赞一下（提交）
            $(".confirm").tap(function(){
                var len = $(".user-item .ok").length; //获取指定元素的数量（长度）
                //提交
                var idArr = {}; //定义空数组
                for(var i=0;i<len;i++){
                    idArr[i] = $("#rows li a.ok").eq(i).attr('data-id'); //将元素的id放入数组
                }
                var param = {id:idArr};


                if($(".select-tip").attr('data-play') <= 0) {

                    $("#return-zan").show();
                    $("#return-zan").removeClass("hidden");
                }else{

                    //ajax请求
                    $.post("{:U('Member/Member/vote')}", param, function(data, textStatus, xhr) {
                        console.log(data); //在控制台打印出指定对象
                        if(data.error == 0){
                            var  rest_num= "{$play}";
//                    alert(rest_num);
                            //alert(te);
                            if(rest_num !=0){
                                //成功时返回首页
                                window.location.href = "{:U('gift')}";
                            }else{
                                $("#no6").show();
                            }

                        }else if(data.error == 1){
                            window.location.href = "{:U('Weixin/Remind/index')}";
                        }else{
                            alert("点赞失败，请重新点赞！");
                        }
                    },"json");
                }

            });
//        }







        //初始化分享
        fenxiang("深呼吸体验之旅摄影作品大赛");
        function fenxiang(title,desc){
            //微信分享
            wx.config({
                debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                appId: "{:C('APPID')}", // 必填，公众号的唯一标识
                timestamp: "{$wxKey['timestamp']}", // 必填，生成签名的时间戳
                nonceStr: "{$wxKey['noncestr']}", // 必填，生成签名的随机串
                signature: "{$wxKey['signature']}",// 必填，签名，见附录1
                jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
            });
            wx.ready(function () {
                var shareData = {
                    title: title,
                    desc: "有体验游，有奖品，有创业项目，只因他们是深呼吸粉丝！",
                    link: "http://tp.nidjia.com{:U('Home/Index/notice')}",
                    imgUrl: "{:C('APP_URL')}/Public/img/logo.jpg"
                };
                wx.onMenuShareAppMessage(shareData);
                wx.onMenuShareTimeline(shareData);
            });
            wx.error(function(res){
                alert(res.errMsg);
            });
        }


        $(".share").tap(function(){
            $(".wx-share").removeClass("hidden");
        });
        $(".wx-share").tap(function(){
            $(".wx-share").addClass("hidden");
        });

        $(".close").tap(function(){
            $(this).parents(".prize-remind").addClass("hidden");
        });

    });
</script>
<script>
 //背景音乐开关
    $(function(){
        var audio = $("audio")[0];
        var turn = 0;
        $(".audio_btn").click(function(){
            if(turn){
                turn = 0;
                $(this).find('img').attr('src','__PUBLIC__/img/audio_open.png');
                audio.play();
            }else{
                turn = 1;
                $(this).find('img').attr('src','__PUBLIC__/img/audio_close.png');
                audio.pause();
            }
        });
    });
</script>
</body>
</html>
